Window = {

}

function Window:close()
    Console.log("close", self.name)
    self.active = false
end

function Node.Window(args)
    local node = Node.new()
    node:wh(500, 500)
    node.name = "window"
    node:addComponent(Window)

    if args and args.pad then
        local pad = Node.Sprite():addTo(node)
        pad:wh(love.graphics.getDimensions())
        pad.color = Color.fromHex("#00000061")
        node.windowPad = pad
    end

    local bg = Node.Scale9("roundedBorderBox48"):addTo(node):addComponent(Stretch):addComponent(Align):addComponent(Layout)
    bg.name = "windowBg"
    bg.color = Color.fromHex("#e0f4fc")
    bg.stretchType = StretchType.Both

    local menu = Node.Sprite():addTo(bg)
    menu:addComponent(Stretch)
    menu.color = Color.fromHex("#F53DA596")
    menu.stretchType = StretchType.Horizontal
    menu.height = 30
    local btnClose = Node.Button("关闭"):addTo(menu)
    btnClose.name = "btnClose"
    btnClose:wh(50, 30)
    btnClose:onClick(function ()
        node:close()
    end, node)
    btnClose:addComponent(Align)
    btnClose.alignPercentX = 1
    btnClose.alignOffsetX = -30
    node.closeButton = btnClose

    local content = Node.new():addTo(bg):addComponent(Stretch)
    content:addComponent(Sprite)
    content.color = Color.fromHex("#33333333")
    content.name = "windowContent"
    content.fillLayout = true
    node.windowContent = content
    node.windowBg = bg



    return node
end